package com.lxf.clouduser.bean;

import lombok.Getter;

/**
 * @author 罗兴发
 * @data 2025/6/13 10:28
 * @description：请求类型-枚举类
 */
@Getter
public enum ReqType {
    //枚举内容
    CONN(1, "建立连接"),
    CANCEL(2, "断开连接"),
    ADD_GROUP(10, "创建群组"),
    JOIN_GROUP(20, "加入群组"),
    LEAVE_GROUP(30,"离开群组"),
    DEL_GROUP(40,"删除群组"),
    SEND_NOTICE(50,"发送系统通告"),
    SEND_MSG(100, "发送消息");

    //编号
    private int num;
    //信息
    private String desc;

    ReqType(int num, String desc) {
        this.num = num;
        this.desc = desc;
    }

    //    增加一个根据数值遍历枚举类型
    public static ReqType getTypeByNum(int num) {
        ReqType[] reqTypes = ReqType.values();
        for (ReqType reqType : reqTypes) {
            if (num == reqType.getNum()) {
                return reqType;
            }
        }
        return ReqType.SEND_MSG;
    }
}
